#include "pagescreeninfo.h"
#include "ui_pagescreeninfo.h"

PageScreenInfo::PageScreenInfo(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PageScreenInfo)
{
    ui->setupUi(this);
#ifdef RUN_IN_BOARD

    int sock;
    int res;
    struct ifreq ifr;

    sock = socket(AF_INET, SOCK_STREAM, 0);
    strcpy(ifr.ifr_name, "eth0");
    res = ioctl(sock, SIOCGIFADDR, &ifr);

    printf("IP: %s\n",inet_ntoa(((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr));

    strcpy(ifr.ifr_name, "eth0");
    res = ioctl(sock, SIOCGIFHWADDR, &ifr);

    int i;
    char mac[32];
    for(i = 0; i < 6; ++i)
    {
        sprintf(mac + 3*i, "%02x:", (unsigned char)ifr.ifr_hwaddr.sa_data[i]);
    }
    printf("MAC: %s\n",mac);
#endif
}

PageScreenInfo::~PageScreenInfo()
{
    delete ui;
}
